import org.codehaus.groovy.grails.web.servlet.GrailsApplicationAttributes 
import org.springframework.context.ApplicationContext;
import javax.servlet.ServletContext;

class BootStrap {
	
	def init = { ServletContext servletContext ->		
		
		ApplicationContext ctx = servletContext.getAttribute(GrailsApplicationAttributes.APPLICATION_CONTEXT)			
		def dataSource = ctx.dataSource	
		dataSource.setMinEvictableIdleTimeMillis(1000 * 60 * 30)			
		dataSource.setTimeBetweenEvictionRunsMillis(1000 * 60 * 30)		
		dataSource.setNumTestsPerEvictionRun(3)						
		dataSource.setTestOnBorrow(true)			
		dataSource.setTestWhileIdle(false)			
		dataSource.setTestOnReturn(false)			
		dataSource.setValidationQuery("SELECT 1")			
		// dataSource.properties.each { println it	}			
	}
	
	def destroy = {
	}
} 